package com.dzsw.univer.config;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
@RequiredArgsConstructor
public class WebMvcConfig extends WebMvcConfigurationSupport {

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 配置 css 路径访问的映射
        registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
        // 配置 js 路径访问的映射
        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
        // 配置 images 路径访问的映射
        registry.addResourceHandler("/images/**").addResourceLocations("classpath:/static/images/");
        super.addResourceHandlers(registry);
    }

    @Override
    protected void addFormatters(FormatterRegistry registry) {
        super.addFormatters(registry);
    }
}
